// @FileName  :t2.c
// @Time      :2024/4/25 18:51
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>

struct node {
    int type;
    int n;
    char op;
} s1[1024], s2[1024];//后缀
struct tnode {
    struct tnode *l, *r;
    struct node self;
} *tree[1024];
int ans[1024];
char buf[1024]; //中缀
int pri(char i) {
    if (i == '+' || i == '-') return 1;
    else if (i == '/' || i == '*') return 2;
    else return -1;
}

int ccal(int b, int a, char c) {
    if (c == '+') return a + b;
    else if (c == '-') return a - b;
    else if (c == '*') return a * b;
    else if (c == '/') return a / b;
}

int to2() { // buf->s2
    int top1 = -1, top2 = -1, cnt = -1;
    for (int i = 0; i < strlen(buf); i++) {
        if (buf[i] == '=') break;
        else if (buf[i] == ' ')continue;
        else if (buf[i] == '(') { s1[++top1].type = 1, s1[top1].op = '('; }
        else if (buf[i] == ')') {
            while (s1[top1].op != '(')
                s2[++top2] = s1[top1--];
            top1--;//去掉 (
        } else if (pri(buf[i]) > 0) {
            if (top1 == -1 || s1[top1].op == '(' || (pri(s1[top1].op) < pri(buf[i])))
                s1[++top1].op = buf[i], s1[top1].type = 1;
            else {
                while (pri(s1[top1].op) >= pri(buf[i])) {
                    s2[++top2] = s1[top1--];
                }
                s1[++top1].op = buf[i], s1[top1].type = 1;
            }
        } else if (buf[i] >= '0' && buf[i] <= '9') {
            int cur = 0;
            while (buf[i] >= '0' && buf[i] <= '9')
                cur = cur * 10 + buf[i++] - '0';
            s2[++top2].n = cur;
            s2[top2].type = 0;
            i--;
        }
    }
    while (top1 >= 0)
        s2[++top2] = s1[top1--];
    return top2;
}

void out(struct tnode *cur) {
    if (cur->self.type == 0) printf("%d ", cur->self.n);
    else printf("%c ", cur->self.op);
}

int main() {
    setbuf(stdout, NULL);
    gets(buf);
    int len = to2();
    int cnt = -1;
//    for (int i = 0; i <= len; i++) {
//        if (s2[i].type == 0) printf("%d ", s2[i].n);
//        else printf("%c ", s2[i].op);
//    }
    for (int i = 0; i <= len; i++) {
        if (s2[i].type == 0) {//num
            struct tnode *new = (struct tnode *) malloc(sizeof(struct tnode));
            new->self = s2[i];
            new->l = new->r = NULL;
            tree[++cnt] = new;
        } else {
            struct tnode *new = (struct tnode *) malloc(sizeof(struct tnode));
            new->self = s2[i];
            new->r = tree[cnt--];
            new->l = tree[cnt--];
            tree[cnt + 1] = tree[cnt + 2] = NULL;
            tree[++cnt] = new;
        }
    }
    out(tree[0]);
    out(tree[0]->l);
    out(tree[0]->r);
    puts("");
    cnt = -1;
    for (int i = 0; i <= len; i++) {
        if (s2[i].type == 0) ans[++cnt] = s2[i].n;
        else {
            int res = ccal(ans[cnt], ans[cnt - 1], s2[i].op);
            ans[--cnt] = res;
        }
    }
    printf("%d", ans[0]);
}